package Text;

import java.util.Random;
import java.util.Scanner;

public class 猜正反面 {
    public static void main(String[] args) {
        Random r = new Random();
        Scanner sc = new Scanner(System.in);
        System.out.println("此时你遇到了一个不关乎取舍，权和利弊的问题。\n你决定让电脑抛硬币来决定。");
        int bool,z = 0,f = 0;
        do {
            int jqw = r.nextInt(2);
            System.out.print("请输入一个1(正面)或者0（反面）(2退出)：");
            bool = sc.nextInt();
            if (bool < 0 || bool > 3){
                System.out.println("你的输入错误，请重新输入。");
            } else if (bool == jqw) {
                System.out.println("\t猜对了");
                z++;
            } else if (bool != jqw && bool != 2) {
                System.out.println("\t猜错了");
                f++;
            }
        }while (bool != 2);
        System.out.printf("你猜对%d，猜错%d。",z,f);
    }
}
